import itertools

from openpyxl import load_workbook
# 下面的前提是 完成1.新建与保存.py后
wb = load_workbook(rf'')
wb1 = load_workbook(rf'D:\Desktop\mynewlearn\my1.xlsx')
sheet = wb['第4次梳理-加回零报 (2)']
sheet1 = wb1['第4次梳理-加回零报 (2)']

max_row = sheet.max_row

n = 4
start = sheet.max_row + 1
end = 0
count = 0
while n < sheet.max_row:
    print(f'n={n},start={start},end={end}')
    if sheet[F'N{n}'].value != "贵阳市":
        if start == sheet.max_row + 1:
            start = n
    else:
        end = n
        if start < end:
            sheet.delete_rows(start,end-start)
            n = start-1
            end = 0
            start = sheet.max_row + 1
            print(f'删除')
    n += 1

if start < sheet.max_row + 1:
    sheet.delete_rows(start, sheet.max_row - start + 1)
    print(f'删除')



# sheet1.append(row_list)


# 创建后保存的路径
wb.save(r'D:\Desktop\mynewlearn\my1.xlsx')